﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ScriptEditor.Commands
{
    class Command_SpriteRotation : Command
    {
        public string name
        {
            get
            {
                return Value1;
            }
            set
            {
                Value1 = value;
            }
        }
        public Rotate rotateMode
        {
            get
            {
                return Enum.TryParse(Value2, out Rotate result) ? result : Rotate.LocalAxisAdd;
            }
            set
            {
                Value2 = value.ToString();
            }
        }
        public float duration
        {
            get
            {
                return float.TryParse(Value3, out float result) ? result : 0.5f;
            }
            set
            {
                Value3 = value.ToString();
            }
        }
        public float angel
        {
            get
            {
                float result = float.TryParse(Value4, out result) ? result : 0;
                return result;
            }
            set
            {
                Value4 = value.ToString();
            }
        }
        public int loopCount
        {
            get
            {
                return int.TryParse(Value5, out int result) ? result : 1;
            }
            set
            {
                Value5 = value.ToString();
            }
        }
        public Loop loopType
        {
            get
            {
                return (Loop)(int.TryParse(Value6, out int result) ? result : 2);
            }
            set
            {
                Value6 = ((int)value).ToString();
            }
        }
        public Command_SpriteRotation()
        {
            CommandType = COMMANDTYPE.SpriteRotation;
            name = "请输入图片名称";
            rotateMode = Rotate.LocalAxisAdd;
            duration = 0.5f;
            angel = 360;
            loopCount = 1;
            loopType = Loop.Incremental;
        }
        public Command_SpriteRotation(string Name, Rotate RotateMode, float Duration, float Angle, int LoopCount, Loop LoopType)
        {
            CommandType = COMMANDTYPE.SpriteRotation;
            name = Name;
            rotateMode = RotateMode;
            duration = Duration;
            angel = Angle;
            loopCount = LoopCount;
            loopType = LoopType;
        }
        public override string ToString()
        {
            return CommandType.ToString() + ":\n" + "图片旋转:" + name+"到"+angel.ToString();
        }
    }
}
